<template>
    <div class="photo-info">
        <header>
            <h2 class="title">{{ info.title }}</h2>
            <p class="mui-ellipsis">
                <span>发表时间：{{ info.add_time | date }}</span>
                <span>点击次数：{{ info.click }}次</span>
            </p>
        </header>

        <div class="thumb-img">
            <img class="preview-img" v-for="(item, index) in thumbImgList" :key="item.id" :src="item.src" height="100"
                 @click="$preview.open(index, thumbImgList)">
        </div>
        <div class="content" v-html="info.content"></div>

        <!-- 评论组件 -->
        <Comment :commentId="$route.params.id"></Comment>
    </div>
</template>

<script>
    // 使用 Comment 组件

    export default {
        created() {
            this.getImgInfo()
        },
        data() {
            return {
                info: {}
            }
        },
        methods: {
            getImgInfo() {
                var url = `api/getimageInfo/${this.$route.params.id}`;

                this.$http.get(url)
                    .then(resp => {
                        var data = resp.data;
                        if (data.status === 0) {
                            this.info = data.message[0]
                        }
                    })
            }
        }

    }
</script>

<style lang="scss" scoped>
    .photo-info {
        padding-left: 3px;
        padding-right: 3px;

        .thumb-img {
            border-top: 1px solid #ccc;

            img {
                margin: 8px;
                box-shadow: 0 0 15px #ccc;
            }
        }

        header {
            padding-top: 5px;
        }

        .title {
            font-size: 18px;
            color: #26a2ff;
            text-align: center;
        }

        .mui-ellipsis {
            display: flex;
            justify-content: space-between;
            padding: 0 3px;
        }

        .content {
            font-size: 14px;
            line-height: 28px;
            padding-top: 20px;
        }
    }
</style>
